{include file="public/header" /}
<link rel="stylesheet" href="__ORG__/validform/css/validform.css">
<script type="text/javascript" src="__ORG__/validform/js/Validform_v5.3.2_min.js"></script>
<style type="text/css">
    td > select { width: 100px;height: 30px;margin-right: 10px; }
    .inputxt { width: 200px; height: 30px; text-align: left;}
</style>
<!--面包屑导航 开始-->
<div class="crumb_warp">
    <!--<i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。-->
    <i class="fa fa-home"></i> <a href="{:url('admin/index/info')}">首页</a> &raquo; <a href="{:url('admin/region/index')}">地区管理</a> &raquo; 添加地区
</div>
<!--面包屑导航 结束-->

<!--结果集标题与导航组件 开始-->
<div class="result_wrap">
    <div class="result_title">
        <h3>地区管理操作</h3>
        {if isset($error)}
        <div class="mark">
            <p>{$error}</p>
        </div>
        {/if}
    </div>
    <div class="result_content">
        <div class="short_wrap">
            <a href="{:url('admin/region/add')}"><i class="fa fa-plus"></i>添加地区</a>
            <a href="{:url('admin/region/index')}"><i class="fa fa-recycle"></i>地区列表</a>
        </div>
    </div>
</div>
<!--结果集标题与导航组件 结束-->

<div class="result_wrap">
    <form action="" method="post" class="demoform">
        <table class="add_tab">
            <tbody>
            <tr>
                <th height="auto"><i class="require">*</i>请选择区域</th>
                <td>
                    <select name="provinceid">
                        <option value="1">请选择省</option>
                        {foreach name="province" item="v"}
                        <option value="{$v.id}">{$v.name}</option>
                        {/foreach}
                    </select>
                    <select name="cityid">
                        <option value="0">请选择市</option>
                    </select>
                    <!--<select name="countyid">
                        <option value="0">请选择县/区</option>
                    </select>-->
                </td>
                <td>( 如未选择地区，将作为省份展示，请正确选择 )</td>
            </tr>
            <tr>
                <th><i class="require">*</i>地区名称：</th>
                <td>
                    <input type="text" class="inputxt" name="name" placeholder="这里输入2到30位名称">
                    <!--<span><i class="fa fa-exclamation-circle yellow"></i></span>-->
                </td>
                <td></td>
            </tr>

            <tr>
                <th></th>
                <td>
                    <input type="submit" value="提交">
                    <input type="button" class="back" onclick="history.go(-1)" value="返回">
                </td>
            </tr>
            </tbody>
        </table>
    </form>
</div>
<script type="text/javascript">
    $(function () {
        $("[name='provinceid']").change(function () {
            $("[name='cityid']").html('<option>loading……</option>');
            var current_province_id = $(this).val();

            $.ajax({
                url: "{:url('region/getCity')}",
                data: {ParentId: current_province_id},
                dataType: 'json',
                type: 'post',
                success: function (item) {
                    var html = '<option value="0">请选择</option>';
                    //var item = re.data;
                    for (var i in item) {
                        html += '<option value="' + item[i]['id'] + '" >' + item[i]['name'] + '</option>';
                    }
                    $("[name='cityid']").html(html);
                }
            })
        })
        /*$("[name='cityid']").change(function () {
         $("[name='countyid']").html('<option>loading……</option>');
         var current_city = $(this).val();
         $.ajax({
         url: "{:url('region/getCounty')}",
         data: {ParentId: current_city},
         dataType: 'json',
         type: 'post',
         success: function (item) {
         var html = '<option value="0">请选择</option>';
         //var item = re.data;
         for (var i in item) {
         html += '<option value="' + item[i]['id'] + '" >' + item[i]['name'] + '</option>';
         }
         $("[name='countyid']").html(html);
         }
         })
         })*/

    })
    //UE.getEditor('editor');

    var demo=$(".demoform").Validform({
        tiptype:3,
        label:".label",
        showAllError:true,
        datatype:{
            "zh1-6":/^[\u4E00-\u9FA5\uf900-\ufa2d]{1,6}$/
        },
        ajaxPost:false
    });

    //通过$.Tipmsg扩展默认提示信息;
    //$.Tipmsg.w["zh1-6"]="请输入1到6个中文字符！";
    demo.tipmsg.w["zh1-6"]="请输入1到6个中文字符！";
    demo.tipmsg.w["*2-20"]="地区标题请输入2到30个字符！";
    demo.tipmsg.w["*3-50"]="地区缩略图不能为空！";

    demo.addRule([{
        ele:".inputxt:eq(0)",
        datatype:"*2-30"
    },
        {
            ele:".inputxt:eq(1)",
            datatype:"*"
        },
        {
            ele:"select",
            datatype:"*"
        },
        {
            ele:"textarea",
            datatype:"*"
        }
    ]);

</script>

{include file="public/footer" /}